package com.logistics.modules.transportationManagement.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.logistics.modules.transportationManagement.entity.CargoEntity;
import com.logistics.modules.transportationManagement.service.CargoService;
import com.logistics.common.utils.PageUtils;
import com.logistics.common.utils.R;



/**
 * 
 *
 * @author HURRICANE
 * @email HURRICANE@nb.com
 * @date 2022-05-06 18:12:10
 */
@RestController
@RequestMapping("/transportationManagement/cargo")
public class CargoController {
    @Autowired
    private CargoService cargoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("transportationManagement:clientorder:list")
    public R list(@RequestParam Map<String, Object> params){

        PageUtils page = cargoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("transportationManagement:clientorder:info")
    public R info(@PathVariable("id") Integer id){

		CargoEntity cargo = cargoService.selectOneById(id);

        return R.ok().put("cargo", cargo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("transportationManagement:clientorder:save")
    public R save(@RequestBody Map<String, Object> params){

		cargoService.saveClientOrderDetails(params);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("transportationManagement:clientorder:update")
    public R update(@RequestBody CargoEntity cargo){

		cargoService.updateById(cargo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("transportationManagement:clientorder:delete")
    public R delete(@RequestBody Integer id){

		cargoService.removeByIds(Arrays.asList(id));

        return R.ok();
    }

}
